﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;

namespace DHM.IRepository {
    public interface IBaseRepository<T> where T : class, new () {
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<bool> AddAsync (T entity);
        Task<bool> DeleteAsync (T entity);
        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<bool> UpdateAsync (T entity);
        Task<T> FindAsync (int id);
        Task<T> FindAsync (Expression<Func<T, bool>> func);

        Task<List<T>> QueryAsync ();

        Task<List<T>> QueryAsync (Expression<Func<T, bool>> func);

        Task<List<T>> QueryAsync (int page, int size, RefAsync<int> total);
        /// <summary>
        /// 分页按条件查询数据
        /// </summary>
        /// <param name="func"></param>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <param name="total"></param>
        /// <returns></returns>

        Task<List<T>> QueryAsync (Expression<Func<T, bool>> func, int page, int size, RefAsync<int> total);
        /// <summary>
        /// 分页按条件查询数据，并制定排序
        /// </summary>
        /// <param name="func"></param>
        /// <param name="func2"></param>
        /// <param name="ordertype"></param>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <param name="total"></param>
        /// <returns></returns>

        Task<List<T>> QueryAsyncOrder (Expression<Func<T, bool>> func, Expression<Func<T, object>> func2, OrderByType ordertype, int page, int size, RefAsync<int> total);
        /// <summary>
        /// 获取满足条件的数据数量
        /// </summary>
        /// <param name="func"></param>
        /// <returns></returns>

        Task<int> GetModuleCount (Expression<Func<T, bool>> func);
    }
}